package com.qf.flash.ui.home.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.qf.flash.R;
import com.qf.flash.model.StrategyBean;
import com.qf.flash.ui.circle.MethodDetailsActivity;
import com.qf.flash.utils.ImageLoader;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;

public class CircleRecommendItem extends BaseRViewItem<Object> {
    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof StrategyBean;
    }

    private Context context;

    public CircleRecommendItem(Activity context) {
        this.context = context;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_circle_recommend;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        StrategyBean strategyBean = (StrategyBean) entity;

        holder.setText(R.id.tv_content, strategyBean.getTitle());
        holder.setText(R.id.tv_author, strategyBean.getAuthor());
        holder.setText(R.id.tv_createDate, strategyBean.getShowTime());
        ImageLoader.load(holder.getmConvertView().getContext(), strategyBean.getImage(), holder.getView(R.id.iv_img));

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MethodDetailsActivity.start(context,strategyBean.getId());
            }
        });
    }
}
